import type { ExhibitionForm, ExhibitionQuery, ExhibitionVO } from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 分页查询展会列表
 * @param params
 * @returns 展会列表
 */
export function exhibitionPage(params?: ExhibitionQuery) {
  return requestClient.get<PageResult<ExhibitionVO>>(
    '/system/exhibition/page',
    { params },
  );
}

/**
 * 查询展会列表
 * @param params
 * @returns 展会列表
 */
export function exhibitionList(params?: ExhibitionQuery) {
  return requestClient.get<ExhibitionVO[]>('/system/exhibition/list', {
    params,
  });
}

/**
 * 导出展会列表
 * @param params
 * @returns 展会列表
 */
export function exhibitionExport(params?: ExhibitionQuery) {
  return commonExport('/system/exhibition/export', params ?? {});
}

/**
 * 查询展会详情
 * @param id id
 * @returns 展会详情
 */
export function exhibitionInfo(id: ID) {
  return requestClient.get<ExhibitionVO>(`/system/exhibition/${id}`);
}

/**
 * 新增展会
 * @param data
 * @returns void
 */
export function exhibitionAdd(data: ExhibitionForm) {
  return requestClient.postWithMsg<void>('/system/exhibition', data);
}

/**
 * 更新展会
 * @param data
 * @returns void
 */
export function exhibitionUpdate(data: ExhibitionForm) {
  return requestClient.putWithMsg<void>('/system/exhibition', data);
}

/**
 * 更新展会状态
 * @param data
 * @returns void
 */
export function exhibitionUpdateStatus(data: ExhibitionForm) {
  return requestClient.putWithMsg<void>(
    `/system/exhibition/changeStatus`,
    data,
  );
}

/**
 * 更新展会是否默认
 * @param data
 * @returns void
 */
export function exhibitionUpdateDefault(data: ExhibitionForm) {
  return requestClient.putWithMsg<void>(
    `/system/exhibition/changeDefault`,
    data,
  );
}

/**
 * 删除展会
 * @param id id
 * @returns void
 */
export function exhibitionRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/system/exhibition/${id}`);
}
